import request from '../utils/request'

// 查询新闻列表
export function getNewsList({ keyword = '', pageNum = 1, pageSize = 10 } = {}) {
  return request({
    url: '/news/query',
    method: 'get',
    params: { keyword, pageNum, pageSize }
  })
}

// 获取最新新闻
export function getLatestNews() {
  return request({
    url: '/news/getLatest',
    method: 'get'
  })
}

// 新增新闻
export function addNews({ title, content }) {
  return request({
    url: '/news/add',
    method: 'post',
    params: { title, content }
  })
}

// 更新新闻
export function updateNews({ id, title, content }) {
  return request({
    url: `/news/update/${id}`,
    method: 'put',
    params: { title, content }
  })
}

// 删除新闻
export function deleteNews(id) {
  return request({
    url: `/news/delete/${id}`,
    method: 'delete'
  })
}